.TH std::experimental::search 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::search \- std::experimental::search

.SH Synopsis
   Defined in header <experimental/algorithm>
   template< class ForwardIterator, class Searcher >

   ForwardIterator search( ForwardIterator first,             (library fundamentals TS)
   ForwardIterator last,

                           const Searcher& searcher );

   Searches the sequence [first, last) for the pattern specified in the constructor of
   searcher.

   Effectively executes searcher(first, last).       \fI(until C++17)\fP
   Effectively executes searcher(first, last).first. \fI(since C++17)\fP

   Searcher need not be CopyConstructible.

   The standard library provides the following searchers:

   default_searcher              standard C++ library search algorithm implementation
                                 \fI(class template)\fP
   boyer_moore_searcher          Boyer-Moore search algorithm implementation
                                 \fI(class template)\fP
   boyer_moore_horspool_searcher Boyer-Moore-Horspool search algorithm implementation
                                 \fI(class template)\fP

.SH Parameters

    This section is incomplete

.SH Return value

   Returns the result of searcher.operator(), that is, an iterator to the location at
   which the substring is found or a copy of last if it was not found.

.SH Complexity

   Depends on the searcher.

.SH Example


// Run this code

 #include <experimental/algorithm>
 #include <experimental/functional>
 #include <iostream>
 #include <string>

 int main()
 {
     std::string in = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed "
                      "do eiusmod tempor incididunt ut labore et dolore magna aliqua";
     std::string needle = "pisci";
     auto it = std::experimental::search(in.begin(), in.end(),
                   std::experimental::make_boyer_moore_searcher(
                       needle.begin(), needle.end()));
     if (it != in.end())
         std::cout << "The string " << needle << " found at offset "
                   << it - in.begin() << '\\n';
     else
         std::cout << "The string " << needle << " not found\\n";
 }

.SH Output:

 The string pisci found at offset 43

.SH See also

   search searches for a range of elements
          \fI(function template)\fP

.SH Categories:
     * Noindexed pages
     * Todo without reason
